#include <iostream>
using namespace std;

//定义"容器"类, 可以存放若干个整数
class Array{
public:
	Array (size_t size):m_data(new int[size]), m_size(size) {}
	~Array (void) {
		delete[] m_data;
		m_data = NULL;
	}
	int&  operator[] (size_t i) {
		//非常对象调用, 返回左值
		return m_data[i];
	}
	const int& operator[] (size_t i) const {
		//常对象调用, 返回右值
		return m_data[i];
	}
private:
	int *m_data;
	size_t m_size;
};

int main (void)
{
	Array arr(10);
	for (int i = 0; i < 10; i++) {
		arr[i] = i;
	}
	const Array& rarr = arr;
	for (int i = 0; i < 10; i++) {
		cout << rarr[i] << endl;
	}
	return 0;
}

